package com.lzh.cli.command;

import cn.hutool.core.bean.BeanUtil;
import com.lzh.generator.MainGenerator;
import com.lzh.model.MainTemplateConfig;
import lombok.Data;
import picocli.CommandLine;

import java.util.concurrent.Callable;

/**
 * @author lzh
 * @version 1.0
 * @date 2025/3/30
 */
@CommandLine.Command(name = "generate", mixinStandardHelpOptions = true)
@Data
public class GenerateCommand implements Callable<Integer> {

    /**
     * 是否生成循环
     */
    @CommandLine.Option(names = {"-l", "--loop"}, description = "是否循环", interactive = true, arity = "0..1", echo = true)
    private boolean loop;

    /**
     * 作者信息
     */
    @CommandLine.Option(names = {"-a", "--author"}, description = "作者名称", interactive = true, arity = "0..1", echo = true)
    private String author = "lzh";

    /**
     * 输出信息
     */
    @CommandLine.Option(names = {"-o", "--outputText"}, description = "输出文本", interactive = true, arity = "0..1", echo = true)
    private String outputText = "输出结果";

    @Override
    public Integer call() throws Exception {
        MainTemplateConfig mainTemplateConfig = new MainTemplateConfig();
        BeanUtil.copyProperties(this, mainTemplateConfig);
        MainGenerator.doGenerate(mainTemplateConfig);
        return 0;
    }
}
